#include "app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    Buffer *buffer = app_buffer_init(300);
    char data[255];
    for (int i = 0; i < 255; i++)
    {
        data[i] = 'a';
    }
    app_buffer_write(buffer, data, 255);
    char data_buf[300];
    int len = app_buffer_read(buffer, data_buf, 300);
    log_debug("读取数据长度：%d，内容：%.*s", len, len, data_buf);
    return 0;
}

/*
int main(int argc, char const *argv[])
{

    // 初始化缓冲区
    Buffer *buffer = app_buffer_init(15);
    // 写数据1
    app_buffer_write(buffer, "abcde", 5);
    // 写数据2
    app_buffer_write(buffer, "fghijk", 6);
    // 读取数据1
    char data_buf[10];
    int len = app_buffer_read(buffer, data_buf, 10);
    log_debug("读取数据1: %.*s, len=%d", len, data_buf, len);
    // 读取数据2
    char data_buf2[10];
    int len2 = app_buffer_read(buffer, data_buf2, 10);
    log_debug("读取数据2: %.*s, len=%d", len2, data_buf2, len2);

    // 读取数据3  错误：没有数据
    // char data_buf3[10];
    // int len3 = app_buffer_read(buffer, data_buf3, 10);
    // log_debug("读取数据3: %.*s, len=%d", len3, data_buf3, len3);

    // 错误：写入的数据过多
    // app_buffer_write(buffer, "aaaaaaaaaaaaaaa", 15);


    return 0;
}
*/